﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ComputerGraphics.Geometry;

namespace ComputerGraphics.Utils
{
    public static class GeometryUtils
    {

        public static Point3D CalculateRefraction(Point3D i, Point3D n, double eta)
        {
            double product = i * n;
            double coeff = eta * product - Math.Sqrt(1 - eta * eta * (1 - product * product));

            return n * coeff - i * eta;
        }

        public static Point3D CalculateSymmetric(Point3D i, Point3D n)
        {
            double product = i * n;
            Point3D proj = n * product;
            Point3D delta = proj - i;

            return i + 2 * delta;
        }

        public static double CalculateArea(Point3D a, Point3D b, Point3D c)
        {
            return ((b - a) ^ (b - c)).Norm / 2;
        }
    }
}
